package com.xiaochong.tir.manager.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaochong.tir.common.data.mapper.ExchangeInfoMapper;
import com.xiaochong.tir.common.data.mapper.ListedCompanyIndexMapper;
import com.xiaochong.tir.common.data.mapper.NonListedCompanyIndexMapper;
import com.xiaochong.tir.common.data.po.ExchangeInfo;
import com.xiaochong.tir.common.data.po.SyArea;
import com.xiaochong.tir.common.data.vo.ApiResultVo;
import com.xiaochong.tir.common.data.vo.ExchangeIndexVo;
import com.xiaochong.tir.common.data.vo.ExchangeInfoVo;
import com.xiaochong.tir.common.util.ApiResultCodeUtils;
import com.xiaochong.tir.manager.config.druid.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * 此类为[基础代码]自动生成,已经拥有基本的增删改成操作 
 * <其他请自行扩展>
 * @author cx
 * @time 2018-04-26 09:56
 * 
 */
@Service
public class ExchangeInfoService {
 
      
    @Autowired
	private ExchangeInfoMapper exchangeInfoDao;

    @Autowired
    private ListedCompanyIndexMapper listedCompanyIndexMapper;

    @Autowired
    private NonListedCompanyIndexMapper nonListedCompanyIndexMapper;

	
	/**
     * 新增
     * @param entity 
     * @param session
     */
	@Operation
    @Transactional
    public int insertSelective (ExchangeInfo entity) { 
     return this.exchangeInfoDao.insertSelective(entity);
    }	
    
    /**
     * 批量新增
     * @param list 
     * @param session
     */
    public void insertBatch(List<ExchangeInfo> list) {
           
          this.exchangeInfoDao.insertBatch(list);

    }
    
    /**
     * 根据主键修改单条数据
     * @param entity 
     * @param session
     */
    @Operation
    @Transactional
    public int updateByPrimaryKey(ExchangeInfo entity,ExchangeInfo old) {
           return this.exchangeInfoDao.updateByPrimaryKey(entity);
    }
    
    /**
     * 根据主键批量修改数据
     * @param list 
     * @param session
     */
    public void updateBatch(List<ExchangeInfo> list) {
           
          this.exchangeInfoDao.updateBatch(list);
    }
    
    /**
     * 根据主键查询单条数据
     * @param id
     */
    public ExchangeInfo selectByPrimaryKey(Integer id) {
            return this.exchangeInfoDao.selectByPrimaryKey(id);
    }
    
    /**
     * 根据条件查询单条记录
     * @param entity 
     */
    public ExchangeInfo selectByEntity(ExchangeInfo entity) {
           return this.exchangeInfoDao.selectByEntity(entity);
    }

    
    /**
     * 根据条件查询Id
     * @param entity 
     */
    public Integer selectById(ExchangeInfo entity) {
           return  this.exchangeInfoDao.selectById(entity);
    }
    
     /**
     * 根据条件查询Ids
     * @param entity 
     */
    public List<Integer> selectByIds(ExchangeInfo entity) {
        return  this.exchangeInfoDao.selectByIds(entity);
    }
    
     /**
     * 根据主键删除单条记录
     * @param id
     */
    public void deleteByPrimaryKey(Integer id) {
           this.exchangeInfoDao.deleteByPrimaryKey(id);
    }
    
    /**
     * 根据主键删除多条记录
     * @param list
     */
    public void deleteBatch(List<Integer> list) {
           this.exchangeInfoDao.deleteBatch(list);
    }
    
     /**
     * 根据某些条件删除
     * @param entity
     */
    public void deleteBatch(ExchangeInfo entity) {
           this.exchangeInfoDao.deleteByEntity(entity);
    }


    /**
     * 根据条件查询多条记录
     * @param entity
     */
    public PageInfo<ExchangeInfo> selectByEntityList(ExchangeInfo entity,Integer pageIndex,Integer pageSize) {
        PageHelper.startPage(pageIndex,pageSize);
        return new PageInfo<ExchangeInfo>(this.exchangeInfoDao.findList(entity));
    }
    public List<ExchangeInfoVo> selectExchangeList(ExchangeInfoVo entity) {
        return this.exchangeInfoDao.selectExchangeList(entity);
    }

    public List<SyArea> getCountryName() {

        return this.exchangeInfoDao.getCountryName();
    }

    public List<SyArea> getCity(Integer id) {
        return this.exchangeInfoDao.getCity(id);
    }

    public List<SyArea> getDistrict(Integer id) {
        return this.exchangeInfoDao.getDistrict(id);
    }

    public SyArea getCounName(int district) {
        return this.exchangeInfoDao.getCounName(district);
    }

    public List<ExchangeInfo> getExchangeInfo() {
        return this.exchangeInfoDao.getExchangeInfo();
    }
}